<?
	$_SESSION['url'] = getURL();
	if(isset($_GET['us_id'])){
		$us_id = intval($_GET['us_id']);
	}else{
		reHome($urlHome);
	}
	$rs = $db->query("SELECT * FROM ".$prefix."nguoidung WHERE u_id = '".$us_id."'");
	$row = $db->fetch_array($rs);
	//
	$u_id = $row[u_id];
	$u_capdo = $row[u_capdo];
	$u_name = stripslashes($row[u_name]);
	$u_email = stripslashes($row[u_email]);
	$u_tenshop = stripslashes($row[u_tenshop]);
	$u_diachi = stripslashes($row[u_diachi]);
	$u_website = stripslashes($row[u_website]);
	$u_congty = stripslashes($row[u_congty]);
	$u_avatar = $PathThumbFile . $row[u_avatar];
	$u_quocgia = $row[u_quocgia];
	$day = loadNgayThangNam($row[u_ngaysinh],0);
	$month = loadNgayThangNam($row[u_ngaysinh],1);
	$year = loadNgayThangNam($row[u_ngaysinh],2);
	$dtcodinh = stripslashes($row[u_dienthoaicodinh]);
	$dtdidong = stripslashes($row[u_dienthoaididong]); 
	$u_loaigiayto = split(";",$row[u_loaigiayto]);
	$u_nickchat = $row[u_nickchat];
	$u_gioithieubanthan = $myString->unQuote(stripslashes($row[u_gioithieubanthan]));
	$u_thongtinthanhtoan = $myString->unQuote(stripslashes($row[u_thongtinthanhtoan]));
	$u_chuky = $myString->unQuote(stripslashes($row[u_chuky]));
	$u_gioitinh = $row[u_gioitinh];
	$u_tinhthanh = layTinhThanh($row[u_tinhthanh]);
	$u_dienthoaicodinh = stripslashes($row[u_dienthoaicodinh]);
	$u_dienthoaididong = stripslashes($row[u_dienthoaididong]);
	$u_ngaydangki = format_date($row[u_ngaydangki]);
	
	
	/////////////////SUBMIT FORM THONG TIN THANH TOAN/////////////////////
	if(isset($_POST['t3toan'])){
		if($_SESSION['uid'] == $us_id){
			if($_POST['t3toan'] == 1){
				$thongtinthanhtoan = addslashes($_POST['thongtinthanhtoan']);
				$db->query("UPDATE ".$prefix."nguoidung SET u_thongtinthanhtoan = '".$thongtinthanhtoan."' WHERE u_id = '".$us_id."'");
				Redirect("Cập nhật thông tin thanh toán thành công !",$url);
			}
		}
	}
	////////////////////////////////////
	
	/////////////SUBMIT FORM MESSAGE /////////////////////////////////////
	if(isset($_POST['msgSubmit'])){
		  if($_SESSION['is_login'] == true){
				if($_POST['msgSubmit'] == 1){
					$shoutBoxMessage = addslashes($_POST['shoutBoxMessage']);
					$db->query("INSERT INTO ".$prefix."tinnhan(tn_nguoinhan,tn_nguoigui,tn_chitiet,tn_thoigian) VALUES('".$us_id."','".$_SESSION['uid']."','".$shoutBoxMessage."',now())");
					header("Location: ".$root."/shop-".$us_id."/".$u_name."");
				}
		  }
	}
	/////////////////////////////////////////////////////////////////////
	
	//////////////////////////////////DELETE MESSAGE ////////////////////////////
	if( (isset($_GET['act'])) && ($_GET['act'] == 'deleteMsg') ){
		if($_SESSION['uid'] == $us_id){
			if(isset($_GET['mid'])){
				$mid = intval($_GET['mid']);
				$db->query("DELETE FROM ".$prefix."tinnhan WHERE tn_id = '".$mid."'");
			}
		}
	}
	////////////////////////////////
?>

<div id="linkPath">

<div class="linkPath">
    <div class="linkPath-text">    
        <div><a href="<?=$root?>/trang-chu/">Trang chủ</a></div><div><a><?=$u_name?></a></div>
    </div> 
</div>
    </div>
<div id="page-content">
        

<div class="personalPage">
	<div class="panel-left">
        <!-- Thông tin thành viên { -->        
		<div class="profile">    
			<div class="profile-content">
				<div class="header">Thông tin thành viên</div>
				<div class="content">
					<div class="left-panel">
						<div class="picture">
							<img src="<?=$root?>/<?=$u_avatar?>" alt="<?=$u_name?>" onerror="this.src='<?=$root?>/themes/images/noavatar.jpg';" width="120"/>                    
						</div>
						<div style="text-align:left; padding-left: 5px; color:#DB5300;">
							<a href="<?=$root?>/gui-tin-nhan/<?=$u_name?>">Gửi tin nhắn riêng</a>
							<br/>
							<a href="<?=$root?>/san-pham/<?=$u_id?>/<?=$u_name?>" >Xem sản phẩm</a>
						</div>
						<div>
							<?
								if($_SESSION['uid'] != $us_id){
								
							?>
							 <p style="text-align: left; padding-left:35px;"><a href="<?=$root?>/ket-ban/<?=$us_id?>" >Kết bạn</a></p>
							<? }?>
						</div>                    
					</div>
					<div class="right-panel">
						<div class="info-profile">
							<div class="slogan">
								<div class="corner-round-profile-slogan-pointer"></div>
								<div class="corner-round-profile-slogan-top-right">
									<div class="corner-round-profile-slogan-top-left">
										<div class="corner-round-profile-slogan-top-bg"></div>
									</div>
								</div>
								<div class="corner-round-profile-slogan-body">
									<div id="edit-inline">Chào mừng các bạn đến với <?=$u_tenshop?></div>
								</div>
					   
								<div class="corner-round-profile-slogan-bottom-right">
									<div class="corner-round-profile-slogan-bottom-left">
										<div class="corner-round-profile-slogan-bottom-bg"></div>
									</div>
								</div>
							</div>
							<div class="info">
								<div><label>Tài khoản</label>: <span class="username"><?=$u_name?></span></div>
								<div><label>Tên shop</label>: <span style="font-weight:bold;"><?=$u_tenshop?></span></div>
								<div><label>Cấp độ</label>: <span style="font-weight:bold;">Thành viên</span></div>
								
								<div>
								<div style="float: left; width: 120px;"><label>Điện thoại</label>:</div>
								<div style="float: left; width: 340px;"><ul style="float: left;"><li><img style="vertical-align: bottom;" src="<?=$root?>/themes/images/form/phone/mobi-phone.jpg"> <?=$u_dienthoaididong?></li></ul></div>
								</div>
								
								<div>
								<div style="float: left; width: 120px;"><label>&nbsp;</label></div>
								<div style="float: left; width: 340px;"><ul style="float: left;"><li><img style="vertical-align: bottom;" src="<?=$root?>/themes/images/form/phone/desk-phone.jpg"> <?=$u_dienthoaicodinh?></li></ul></div>
								</div>
								
								<div>
									<?
										$ym = loadNickChat(0,$u_nickchat);
									?>
									<div style="float: left; width: 120px;"><label>Nick Chat</label>:</div>
									<div style="clear:both"></div>
									<div style="float: left; width: 340px;">
										<ul style="float: left;">
											<li>YM: <img style="vertical-align: top;" src="http://mail.opi.yahoo.com/online?u=<?=$ym?>&m=g&t=5"> <a href="ymsgr:sendim?<?=$ym?>" ><?=$ym?></a>
											</li>
										</ul>
									</div>
								</div>
								<div style="clear:both"></div>
								<div>
								<div style="float: left; width: 120px;"><label>Tham gia ngày</label>:</div> 
								<div style="float: left; width: 340px;"><?=$u_ngaydangki?></div>
								</div>
								<div style="clear:both"></div>
								<div>
								<div style="float: left; width: 120px;"><label>Khu vực</label>:</div> 
								<div style="float: left; width: 340px;"><?=$u_tinhthanh?></div>
								</div>
								<div style="clear:both"></div>
								<div>
								<div style="float: left; width: 120px;"><label>Địa chỉ liên lạc</label>:</div>
								<div style="float: left; width: 340px;"><?=$u_diachi?></div>
								</div>
								<div style="clear:both"></div>
								<div>
								<div style="float: left; width: 120px;"><label>Tự bạch</label>: </div>
								<div style="float: left; width: 340px;"><p><span><?=$u_gioithieubanthan?></span></p></div>
								</div>								
							</div>
						</div>    
						
					</div>            
				</div>
				    
			</div>
		</div>      
		<!-- } Thông tin thành viên -->
      
	  
	    <!-- Sảm phẩm hot { -->
        

		<div class="hot-product-personal">
			<div class="hot-product-personal-fix">
			<div class="top">Sản phẩm HOT</div>
			<div class="main">
				<div id="mask" class="mask">
					<ul id="product-hot">
				   <?
						$rs2 = $db->query("SELECT * FROM ".$prefix."sanpham WHERE t_nguoidang = '".$us_id."' AND t_noibat = 1 LIMIT 6");
						while($row2 = $db->fetch_array($rs2)){
						$t_id = $row2[t_id];
						$t_tieude = stripslashes($row2[t_tieude]);
						$t_giaban = showprice($row2[t_giaban]);
						$t_loaitien = loadLoaiTien($row2[t_loaitien]);
						if($t_loaitien == "VNĐ"){
							$t_loaitien = "đ";
						}
						$t_hinhanh = $PathThumbFile . $row2[t_hinhanh];
				   ?>     
							<li>
								<p class="picture">			            
									<a target="_blank" href="<?=$root?>/chi-tiet-san-pham/<?=$t_id?>/<?=$myString->vietdecode($t_tieude)?>" class="product-name" title="<?=$t_tieude?>">
										<img width="100px" style="vertical-align:middle" alt="<?=$t_tieude?>" height="100px" src="<?=$root?>/<?=$t_hinhanh?>" />
									</a> 
								</p>
								<p class="price"><?=$t_giaban?><?=$t_loaitien?></p>
							</li>
					<? } ?>
					</ul>
				</div>
			</div>
			</div>
		</div>    
        <!-- } Sảm phẩm hot -->
		
		
		
        <!-- Tab info { -->
<script language="javascript">
	function tabinfo(id){
		var a = document.getElementById('comment');
		var a1 = document.getElementById('tab-comment');
		
		var b = document.getElementById('product');
		var b1 = document.getElementById('tab-product');
		
		var c = document.getElementById('bankinfo');
		var c1 = document.getElementById('tab-general');
		
		var d = document.getElementById('friend');
		var d1 = document.getElementById('tab-friend');
		if(id == 0){
			a.style.display = 'inline';
			b.style.display = 'none';
			c.style.display = 'none';
			d.style.display = 'none';
			//
			a1.className = 'active';
			b1.className = '';
			c1.className = '';
			d1.className = '';
		}else if(id == 1){
			b.style.display = 'inline';
			a.style.display = 'none';
			c.style.display = 'none';
			d.style.display = 'none';
			//
			b1.className = 'active';
			a1.className = '';
			c1.className = '';
			d1.className = '';
		}else if(id == 2){
			c.style.display = 'inline';
			a.style.display = 'none';
			b.style.display = 'none';
			d.style.display = 'none';
			//
			c1.className = 'active';
			a1.className = '';
			b1.className = '';
			d1.className = '';
		}else{
			d.style.display = 'inline';
			a.style.display = 'none';
			b.style.display = 'none';
			c.style.display = 'none';
			//
			d1.className = 'active';
			a1.className = '';
			b1.className = '';
			c1.className = '';
		}
	}
</script>        
	<div class="tab-info">
		<div class="tab-nav">
			<ul>            
				<?
					if($_SESSION['uid'] == $us_id){
				?>
				<li id="tab-comment" class="active"><a href="javascript:void(0);" onclick="tabinfo(0);"><span>Comment mới</span></a></li>
				<li id="tab-product"><a href="javascript:void(0);" onclick="tabinfo(1);"><span>Sản phẩm mới</span></a></li>
				<? }else{ ?>
				<li id="tab-product" class="active"><a href="javascript:void(0);" onclick="tabinfo(1);"><span>Sản phẩm mới</span></a></li>
				<? } ?>
				<li class="" id="tab-general"><a href="javascript:void(0);" onclick="tabinfo(2);"><span>Thông tin thanh toán</span></a></li>
				<li class="" id="tab-friend"><a href="javascript:void(0);" onclick="tabinfo(3);"><span>Bạn bè</span></a></li>

			</ul>                              
			<p class="tab-bar"></p>
		</div>            
		<div id="tab-content">

		<?
			if($_SESSION['uid'] == $us_id){
		?>

		<!-- BEGIN NEW COMMENT -->

		<div class="new-comment" id="comment">
			<div class="corner-round-02-top-right">
				<div class="corner-round-02-top-left">
					<div class="corner-round-02-top-bg"></div>
				</div>
			</div>
			<div class="corner-round-02-body" style="overflow: hidden; height: auto; padding-bottom: 0px;">

				<p class="header">Comments Mới</p>        
				<p class="line"></p>
				
				<?	
					$st = 0;
					$rs4 = $db->query("SELECT * FROM ".$prefix."sanpham_comment AS A, ".$prefix."sanpham AS B WHERE A.cm_sanpham_id = B.t_id AND B.t_nguoidang = '5' AND B.t_hienthi = 1 order by A.cm_id DESC LIMIT 10");
					while($row4 = $db->fetch_array($rs4)){
					$t_tieude = $myString->unQuote(stripslashes($row4[t_tieude]));
					$cm_content = $myString->unQuote(stripslashes($row4[cm_content]));
					$cm_nguoidung = $row4[cm_nguoidung];
					$cm_avatar = $PathThumbFile . loadAvatar($cm_nguoidung);
					$cm_ten_nguoidung = tenNguoiDung($cm_nguoidung);
					$cm_date = format_date_time($row4[cm_date]);
					$st++;
				?>
					   
						<div class="comment-item-rows">                               
							<div class="comment-item-col-avatar">
								<p><a href="<?=$root?>/shop-<?=$cm_nguoidung?>/<?=tenNguoiDung2($cm_nguoidung)?>" title="<?=$cm_ten_nguoidung?>"><img alt="<?=$cm_ten_nguoidung?>" src="<?=$root?>/<?=$cm_avatar?>" width="60" height="60"></a></p><p><a href="<?=$root?>/shop-<?=$cm_nguoidung?>/<?=tenNguoiDung2($cm_nguoidung)?>" title="<?=$cm_ten_nguoidung?>"><?=$cm_ten_nguoidung?></a></p>
							</div>
							<div class="comment-item-col-product-name">
								<p>

									<a href="javascript:void(0);" class="product-name"><?=$t_tieude?></a>
								</p>
								<p style="text-align: left;"><?=$cm_content?></p>
							</div>
							<div style="clear: both; background-color: rgb(255, 255, 255); text-align: right; font-size: 8pt; line-height: 14px; margin-bottom: 2px; color: rgb(102, 102, 102);"><?=$cm_date?></div> 
						</div>
						<?
							if($st != $db->num_rows($rs4)){
						?>
							<p class="line"></p>
						<? } ?>
					<? } ?>  
						
				<p class="clearBoth"></p>

			</div> 
		</div>

	<? }else{ ?>
		<div id="tab-comment" style="display:none;"></div>
		<div id="comment" style="display:none;"></div>
	<? }?>


	<!-- BEGIN NEW PRODUCT -->
	   
	<div class="new-products" id="product" <? if($_SESSION['uid'] == $us_id){ echo "style=\"display:none;\""; }else{ echo "style=\"display:block\""; } ?>>
		<div class="corner-round-02-top-right">
			<div class="corner-round-02-top-left">
				<div class="corner-round-02-top-bg"></div>
			</div>
		</div>
		<div class="corner-round-02-body" style="overflow: hidden; height: auto; padding-bottom: 0px;">
		
			<p class="header">Sản phẩm mới</p>                
			<p class="line"></p>
					
				<?
					$st = 0;
					$rs3 = $db->query("SELECT * FROM ".$prefix."sanpham WHERE t_nguoidang = '".$us_id."' ORDER BY t_id DESC LIMIT 10");
					while($row3 = $db->fetch_array($rs3)){
					$st++;
					$t_id = $row3[t_id];
					$t_tieude = stripslashes($row3[t_tieude]);
					$t_giaban = showprice($row3[t_giaban]);
					$t_mota = $myString->unQuote(stripslashes($row3[t_mota]));
					$t_xemgannhat = format_date_time($row3[t_xemgannhat]);
					$t_solanxem = $row3[t_solanxem];
					$t_loaitien = loadLoaiTien($row3[t_loaitien]);
					$t_hinhanh = $PathThumbFile . $row3[t_hinhanh];
				?>	
					<div class="product-item-rows">           
						<div class="product-item-col-picture">
							<p>                                        
								<a title="<?=$t_tieude?>" href="<?=$root?>/chi-tiet-san-pham/<?=$t_id?>/<?=$myString->vietdecode($t_tieude)?>" class="tips product-name">
									<img width="100px" style="vertical-align:middle" alt="Xem chi tiết" height="100px" src="<?=$root?>/<?=$t_hinhanh?>" onerror="this.src='<?=$root?>/themes/images/noimg.jpg';"/>
								</a>                                                                              
							</p>
						</div>
						<div class="product-item-col-name">
							<p>
								<a href="<?=$root?>/chi-tiet-san-pham/<?=$t_id?>/<?=$myString->vietdecode($t_tieude)?>" class="product-name"><?=$t_tieude?></a>
							</p>
							<p class="truncate" style="text-align: left;">
							  <?=$t_mota?>
							</p>
							<p style="font-size:8pt;color:Gray;">
								<?=$t_xemgannhat?> | Xem: <?=$t_solanxem?> | Comments: <?=loadSoComment($t_id)?>   
							</p>  
						</div>
						<div class="product-item-col-price">
							<p>
								<label>Giá bán</label><br />
								<label class="number"><?=$t_giaban?>&nbsp;<?=$t_loaitien?></label>
							</p>
						</div>
					</div>
					
				<? 
					if($st != $db->num_rows($rs3)){
				?>	
					 <p class="product-line"></p>
					 
				<? } ?>

			<? }?>
		<p class="clearBoth"></p> 
		
		</div>
		<p style="text-align: right; margin: 5px;"><a class="view-more" href="<?=$root?>/san-pham/<?=$us_id?>/<?=tenNguoiDung2($us_id)?>">xem thêm</a></p>
	</div>

	<!-- END NEW PRODUCT -->


	<!-- THONG TIN THANH TOAN -->

	<div class="bankinfo" id="bankinfo" style="display:none;">
		<div class="corner-round-02-top-right">
			<div class="corner-round-02-top-left">
				<div class="corner-round-02-top-bg"></div>
			</div>
		</div>
		<div class="corner-round-02-body" style="overflow: hidden; height: auto; padding-bottom: 0px;">
		
			<p class="header">Thông tin thanh toán</p>
			<p class="line"></p>
			<div style="margin: 10px;">
				
				<!-- content -->
				
				<?
					if($u_thongtinthanhtoan != ""){
						echo $u_thongtinthanhtoan;
					}else{
						echo "<b>Chưa có thông tin thanh toán !</b>";
					}
				?>
				
				
				<!-- content --->
				
				
			</div>
	<?
		if($_SESSION['uid'] == $us_id){
	?>		
		<script language="javascript">
			function funt3toan(){
				var a = document.getElementById('ttthanhtoan');
				if(a.style.display == 'none'){
					a.style.display = 'inline';
				}else{
					a.style.display = 'none';
				}
			}
		</script>
			<p style="margin: 10px; text-align: left;"><a href="javascript:void(0);" onclick="javascript:funt3toan();"><img src="<?=$root?>/themes/images/form/button-accept.jpg"></a></p>

			<div id="ttthanhtoan" align="center" style="display:none;">
			<form action="" name="frmThongTinThanhToan" id="frmThongTinThanhToan" method="post">
				<textarea name="thongtinthanhtoan" id="elm1" style="width:80%;height:350px;font-family:Verdana;font-size:10pt;border:solid 1px #CCCCCC"><?=$u_thongtinthanhtoan?></textarea>
				<input type="hidden" name="t3toan" id="t3toan" value="1" />
				<br />
				<input type="submit" name="submit" id="submit" value="Cập nhật" />
			</form>
			</div>
	<? } ?>
			<br />
			<p class="clearBoth">
		</p>
		</div> 
		<div class="corner-round-02-bottom-right">
			<div class="corner-round-02-bottom-left">
				<div class="corner-round-02-bottom-bg"></div>
			</div>
		</div>
	</div>


	<!-- THONG TIN THANH TOAN -->



	<!-- FRIEND LIST -->
	<?
		$rs = $db->query("SELECT * FROM ".$prefix."ketban WHERE kb_uid = ".$us_id." AND kb_trangthai = 1");
	?>        
	<div class="friend-list" id="friend" style="display:none;">
		<div class="corner-round-02-body" style="overflow: hidden; height: auto; padding-bottom: 0px;">

			<p class="header">Danh sách bạn</p>
			<p class="line"></p>
			<p style="margin: 10px;">Tổng số bạn: <?=$db->num_rows($rs)?></p>
			<!-- begin repeater -->
			
					<div class="content">
			   
			  <? if($db->num_rows($rs) != 0){ ?> 
				
						<div class="official">
						<ul>

			  <?
					while($row = $db->fetch_array($rs)){
					$tentv = $myString->cutString2(tenNguoiDung($row[kb_friend_id]),6);
			  ?>  
						<li>		
							<a href="<?=$root?>/shop-<?=$row[kb_friend_id]?>/<?=tenNguoiDung2($row[kb_friend_id])?>" title="<?=tenNguoiDung($row[kb_friend_id])?>"><img class="popup-profile" alt="<?=tenNguoiDung($row[kb_friend_id])?>" src="<?=$root?>/<?=$PathThumbFile . loadAvatar($row[kb_friend_id])?>" width="60" height="60" onerror="this.src='<?=$root?>/themes/images/noavatar.jpg';"></a>
							<a href="<?=$root?>/shop-<?=$row[kb_friend_id]?>/<?=tenNguoiDung2($row[kb_friend_id])?>" title="<?=tenNguoiDung($row[kb_friend_id])?>"><?=$tentv?></a>
						</li>
				 <? } ?>  
						</ul>
						</div> 
					
			 <? }else{ ?>
					<p align="center" style="text-align:center; font-weight:bold;">Chưa có bạn bè nào !</p>
					<br />
			 <? }?>  	
						
						
						
					</div>        
				
			<p class="clearBoth" style="text-align: right;"></p>

		</div> 
		<div class="corner-round-02-bottom-right">
			<div class="corner-round-02-bottom-left">

				<div class="corner-round-02-bottom-bg"></div>
			</div>
		</div>
	</div>

	<!-- END FRIEND LIST -->
			<p class="clearBoth height-space"></p>
		</div>
	</div>
        <!-- } Tab info -->
		
		
		
</div>
	<div class="panel-right">
	
<!-- Bạn bè { -->
        
	<div class="friends">
	<?
	$rs = $db->query("SELECT * FROM ".$prefix."ketban WHERE kb_uid = ".$us_id." AND kb_trangthai = 1");
		
	?>	
			<div class="header">Bạn bè (<?=$db->num_rows($rs)?>)</div
			<!-- begin repeater -->			
			<div class="content">
			
			<? if($db->num_rows($rs) != 0){ ?> 
				<div class="official">
					<ul>
					<?
						while($row = $db->fetch_array($rs)){
						
					?>
						<li>		
							<a href="<?=$root?>/shop-<?=$row[kb_friend_id]?>/<?=tenNguoiDung2($row[kb_friend_id])?>" title="<?=tenNguoiDung($row[kb_friend_id])?>"><img class="popup-profile" alt="<?=tenNguoiDung($row[kb_friend_id])?>" src="<?=$root?>/<?=$PathThumbFile . loadAvatar($row[kb_friend_id])?>" onerror="this.src='<?=$root?>/themes/images/noavatar.jpg';" width="60" height="60"/></a>
							<a href="<?=$root?>/shop-<?=$row[kb_friend_id]?>/<?=tenNguoiDung2($row[kb_friend_id])?>" title="<?=tenNguoiDung($row[kb_friend_id])?>" ><?=$myString->cutString2(tenNguoiDung($row[kb_friend_id]),6)?></a>
						</li>
					<? } ?>	
					</ul>
				</div> 
			
			<? }else{ ?>
			<br />
				<p align="center" style="text-align:center; font-weight:bold;">Chưa có bạn bè nào !</p>
				
			<? }?>		
			</div> 
			<!-- end repeater --> 
			<p class="clearBoth" style="text-align: right; margin-right: 10px;"><a class="view-more" href="<?=$root?>/ban-be/<?=$us_id?>">Xem thêm</a></p>
			<p class="clearBoth"></p>
			<br style="font-size:0px;" />
	</div>
	<!-- } Bạn bè -->
        
	<div class="banner banner-user" id="user-banner"></div>
       
     <!-- Tin nhắn pm { -->
			<?
				function tinnhan(){
					global $root;
					echo "<form action=\"\" name=\"frmMessage\" id=\"frmMessage\" method=\"post\">
					<div class=\"form\">
						<textarea id=\"shoutBoxMessage\" name=\"shoutBoxMessage\" cols=\"30\" rows=\"7\"></textarea>
						<div class=\"button-pm-message\">
							 <div style=\"text-align:right; padding-right:20px;\">
								<span style=\"padding-right:5px;\">
									<img alt=\"\" src=\"<?=$root?>/themes/images/form/public.jpg\" title=\"Cho phép thành viên gởi tin nhắn.\"/>
								</span>
								<input type=\"hidden\" id=\"msgSubmit\" name=\"msgSubmit\" value=\"1\" />
								<input type=\"submit\" value=\"Gửi\" name=\"saveMsg\" id=\"saveMsg\" style=\"height: 30px;width: 100px;background: #f6f7fc;border: 1px solid #d8dfea;margin:10px 10px 10px; font-weight:bold;\" />
							</div> 
							<div style=\"clear: both; margin-bottom: 5px;\"></div>
						</div>
					</div>
				</form>	";
				}
		 
		 ?>       
		<div class="shoutbox">
			<div class="shoutbox-content">
				<p class="header">Tin nhắn (<?=loadSoTinNhan2($us_id)?>)</p>
				<div class="content">
				<?
					if(loadConfigUser($us_id,1) == 0){
						if($_SESSION['is_login'] == true){
							tinnhan();
						}
					}else if(loadConfigUser($us_id,1) == 1){
						if($_SESSION['is_login'] == true){
							$t = false;
							$rs = $db->query("SELECT * FROM ".$prefix."ketban WHERE kb_id = '".$us_id."' AND kb_trangthai = 1");
							while($row = $db->fetch_array($rs)){
								if($row[kb_friend_id] == $_SESSION['uid']){
									$t = true;
								}
							}
							//
							if( ($t == true) || ($_SESSION['uid'] == $us_id) ){
								tinnhan();
							}
						}
					}else{
						if($_SESSION['is_login'] == true){
							if($us_id == $_SESSION['uid']){
								tinnhan();
							}
						}
					}
				?>
		
		
		
		
            <p class="message-bar"></p>
			
            <div id="message-content" class="message-content">
            <!-- CONTENT -->
			<?
				$sql = "SELECT * FROM ".$prefix."tinnhan WHERE tn_nguoinhan = ".$us_id." ORDER BY tn_id DESC";
					$pp=10; 
					$parr=array();
					$parr=paging($sql,$pp);
					$page=$parr[0];
					$limitvalue=$parr[1];
					$numofpages=$parr[2];
					$sql.=" LIMIT $limitvalue, $pp";
				$rs = $db->query($sql);
				while($row = $db->fetch_array($rs)){
				$tn_id = $row[tn_id];
				$tn_nguoigui = $row[tn_nguoigui];
				$tn_chitiet = $myString->unQuote(stripslashes($row[tn_chitiet]));
				$tn_thoigian = format_date_time($row[tn_thoigian]);
			?>    
				<div class="message-row">
				 	<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tr><td width="6%" valign="top">
					 <div>
						 <div class="picture-profile">
						 <a href="<?=$root?>/shop-<?=$tn_nguoigui?>/<?=tenNguoiDung2($tn_nguoigui)?>"><img src="<?=$root?>/<?=$PathThumbFile . loadAvatar($tn_nguoigui)?>" onerror="this.src='<?=$root?>/themes/images/noavatar.jpg';" alt="" title="<?=tenNguoiDung($tn_nguoigui)?>" width="60" height="60"/></a></div>
						 <p class="username"> <a href="<?=$root?>/shop-<?=$tn_nguoigui?>/<?=tenNguoiDung2($tn_nguoigui)?>" title="<?=tenNguoiDung($tn_nguoigui)?>"><?=$myString->cutString2(tenNguoiDung($tn_nguoigui),6)?></a></p>
					 </div>
					</td><td width="94%" valign="top" align="left">
					 <div><?=$tn_chitiet?></div>
					 </td>
					 </tr></table>
						 <div class="line-row"></div>
						 <p class="bottom-bar"><label><?=$tn_thoigian?></label>
						 <?
						 	if($_SESSION['uid'] == $us_id){
						 ?>
						 <a href="<?=$root?>/?mod=thanhvien&us_id=<?=$us_id?>&act=deleteMsg&mid=<?=$tn_id?>"><img src="<?=$root?>/themes/images/form/icon_remove.gif" alt="Xóa" title="Xóa khỏi danh sách." style="vertical-align: middle;"></a>
						 <? } ?>
						 </p>
						 <p class="message-line"></p>
				 </div>
			<? }?>	 
            </div>
			<br />
            <p align="right" class="font">
			 <?php echo page_div( "".$root."/?mod=thanhvien&us_id=".$us_id."&p=%d_pg", "10", ceil ( $numofpages ), $page ); ?>
			 </p>
        </div>
    </div>	
</div>
</div>
        <!-- } Tin nhắn pm -->
    </div>    
</div>
        
  
    <div style="clear:both;"></div>

            